#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
using namespace std;
typedef pair<int, int> PII;
const int N = 2e5 + 10;
int a[N];
int n;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n;
		priority_queue<PII, vector<PII>, greater<PII>>heap;
		bool flag = 0;
		int cnt1 = 0, cnt2 = 0;
		for (int i = 1; i <= n; i++) {
			cin >> a[i];
			heap.push({ a[i],i });
			if (a[i - 1] > a[i])flag = 1;
			if (a[i] & 1)cnt1++;
			else cnt2++;
		}
		if (!flag || cnt1 == n || cnt2 == n)cout << "YES" << endl;
		else {
			/*if (cnt1 == 1 || cnt2 == 1) {
				cout << "NO" << endl;
				continue;
			}*/
			bool flag1 = 0;
			for (int i = 1; i <= n; i++) {
				PII t = heap.top();
				heap.pop();
				if (a[i] % 2 != t.first % 2) {
					flag1 = 1;
					break;
				}
			}
			//cout << "111" << endl;
			if (flag1)cout << "NO" << endl;
			else cout << "YES" << endl;
		}
	}
	return 0;
}